package com.infindo.frame.util;

public class CharactorUtil {

    
    public static int bytesToInt(byte[] bytes) {
        int addr = bytes[3] & 0xFF;
        addr |= ((bytes[2] << 8) & 0xFF00);
        addr |= ((bytes[1] << 16) & 0xFF0000);
        addr |= ((bytes[0] << 24) & 0xFF000000);
        return addr;
    }
    
    public static byte[] intToByte(int i) {
        byte[] abyte0 = new byte[4];
        abyte0[3] = (byte) (0xff & i);
        abyte0[2] = (byte) ((0xff00 & i) >> 8);
        abyte0[1] = (byte) ((0xff0000 & i) >> 16);
        abyte0[0] = (byte) ((0xff000000 & i) >> 24);
        return abyte0;
    }

    
    
    public static void main(String[] args) {
/*        byte[] b = new byte[4];
        b[0] = 0;
        b[1] = 0;
        b[2] = 0;
        b[3] = 20;
        
        int i = bytesToInt(b);
        System.out.println(i);*/
        
        int i = 2147483647;
        
        byte[] bb = intToByte(i);
        for (int j = 0; j < bb.length; j++) {
            System.out.println(bb[j]);
        }
        
        int j = bytesToInt(bb);
        System.out.println(j);
        
    }
}
